<script type="text/javascript">
    function addToBanner (ringtone_id) {
        jQuery.ajax({
            type: 'GET',
            url: '<?php echo url_for('ringtone/addToBanner') ?>',
            data: 'ringtone_id=' + ringtone_id,
            success: function(msg) {
                //alert(msg);
                document.getElementById('btnAddToBanner_' + ringtone_id).innerHTML = "Xóa";
                document.getElementById('btnAddToBanner_' + ringtone_id).onclick=function(){removeFromBanner(ringtone_id); return false;};
            }
        });
    }
    function removeFromBanner (ringtone_id) {
        jQuery.ajax({
            type: 'GET',
            url: '<?php echo url_for('ringtone/removeRtFromBanner') ?>',
            data: 'ringtone_id=' + ringtone_id,
            success: function(msg) {
                //alert(msg);
                document.getElementById('btnAddToBanner_' + ringtone_id).innerHTML = "Thêm";
                document.getElementById('btnAddToBanner_' + ringtone_id).onclick=function(){addToBanner(ringtone_id); return false;};
            }
        });
    }
</script>
<?php
// auto-generated by sfPropelAdmin
// date: 2009/04/20 15:41:44
?>
    <td>
    	<?php echo link_to($ringtone->getName() ? $ringtone->getName() : __('-'), 'ringtone/edit?id='.$ringtone->getId()) ?>
    </td>
    
    <td>
    	<?php echo ($ringtone->getComposedByUser()== 1) ? 'Tự sáng tác' :  $ringtone->getComposerName() ?>
    </td>
    
    <td>
    	<?php echo $ringtone->getUser() ?>
    </td>
    
    <td>
    	<?php echo link_to($ringtone->getRingtoneCategory(), 'ringtone_category/edit?id='.$ringtone->getCategoryId(),'popup=true'); ?>
    </td>
    
    <td>
    	<?php 
    	if($ringtone->getRingtoneOrigin() != NULL)
    	{
	    	switch($ringtone->getRingtoneOrigin()->getIsUpload())
	      	{
	      		case '0': echo 'Thu âm'; break;      	
	      		case '1': echo 'Upload từ backend'; break;
	      		case '2': echo 'Upload từ web'; break;
	      		case '5': echo 'Sàn nhạc'; break;      		
	      		default: break;      	
	      	}
    	}
    	?>
    </td>
    
    <td>
    	<?php echo ($ringtone->getCreatedDatetime() !== null && $ringtone->getCreatedDatetime() !== '') ? date("h:i d/m/Y", strtotime($ringtone->getCreatedDatetime())) : '' ?>
    </td>
    
     <?php if ($nhac == 'chuong' && ($duyet == 'vmschuaduyet' || $duyet == 'roi' || $duyet == 'tuchoi')): ?>
    <td>
    	<?php
		    $c = new Criteria();
		    $c->add(RingtoneStatusPeer::RINGTONE_ID, $ringtone->getId());
		    $ringtoneStatus = RingtoneStatusPeer::doSelectOne($c);
		    echo date("h:i d/m/Y", strtotime($ringtoneStatus->getRtApproveDatetime()));		     
		?>
    </td>
    <?php endif; ?>
    
    <?php if ($nhac == 'cho' && $duyet == 'roi'): ?>
    <td>
    	<?php
            $c = new Criteria();
            $c->add(RingtoneStatusPeer::RINGTONE_ID, $ringtone->getId());
            $ringtoneStatus = RingtoneStatusPeer::doSelectOne($c);
            echo date("h:i d/m/Y", strtotime($ringtoneStatus->getRbtApproveDatetime()));		     
        ?>    
    </td>
    <?php endif; ?>
    
     <?php if ($nhac == 'cho' && $duyet == 'tuchoi'): ?>
    <td>
    	<?php
		    $c = new Criteria();
		    $c->add(RingtoneStatusPeer::RINGTONE_ID, $ringtone->getId());
		    $ringtoneStatus = RingtoneStatusPeer::doSelectOne($c);
		    echo date("h:i d/m/Y", strtotime($ringtoneStatus->getRbtApproveDatetime()));		     
		?>    </td>
    <?php endif; ?>
    
    <?php if ($nhac == 'chuong'): ?>  
    <td>
    	<?php echo get_partial('approve', array('type' => 'list', 'ringtone' => $ringtone, 'mode'=>'rt')) ?>
    </td>
    <?php endif; ?>
    
    <?php if ($nhac == 'cho'): ?>
    <td>
    	<?php echo get_partial('approve', array('type' => 'list', 'ringtone' => $ringtone,'mode'=>'rbt')) ?>
    </td>
    <?php endif; ?>
    
     <?php if ($nhac == 'chuong' && $duyet == 'vmschuaduyet'): ?>
     <td >
		<?php //echo checkbox_tag('vmsapprove[]', $ringtone->getId(), false) ?>
		<input style="width:20px;" type="checkbox" name="vmsapprove[]" id="vmsapprove[]" value="<?php echo $ringtone->getId(); ?>"  />
	 </td>
	 <?php endif; ?>
         
    <?php if ($nhac == 'cho' && $duyet == 'roi'): ?>
        <td>
            <a id="btnAddToBanner_<?php echo $ringtone->getId(); ?>" 
               onclick="<?php if(!RingtoneBannerPeer::checkIsExistBanner($ringtone->getId())) 
                                    echo 'addToBanner('.$ringtone->getId().');return false;'; 
                               else 
                                    echo 'removeFromBanner('.$ringtone->getId().');return false;'; 
                        ?>" 
                    class="" style="width: 100px;" href="">
                <?php if(!RingtoneBannerPeer::checkIsExistBanner($ringtone->getId())) 
                                    echo 'Thêm'; 
                               else 
                                    echo 'Xóa';
                        ?>
            </a>   
        </td>
    <?php endif; ?>